package top.tttfu.logic;

import top.tttfu.dao.DaoFactory;
import top.tttfu.entity.Task;
import top.tttfu.entity.User;
import top.tttfu.ui.UiConsts;
import top.tttfu.ui.panel.TaskLookPanel;
import top.tttfu.util.JDBC;

import javax.swing.*;
import java.awt.*;
import java.util.List;

public class init {

    public static void start(){

        List<Task> list = DaoFactory.getTaskDao().selectTaskByUser(JDBC.getConnection(),new User("taofu",""));
        for(Task task : list){
            JPanel panel = new JPanel(new BorderLayout(20,0));
            panel.setBackground(new Color(69, 186, 121));
//            panel.setLayout(new FlowLayout(FlowLayout.LEFT, 30, 13));
            Dimension preferredSizeListItem = new Dimension(UiConsts.MAIN_WINDOW_WIDTH-245-150, 48);
            panel.setPreferredSize(preferredSizeListItem);


            JLabel label = new JLabel(task.getContent());
            Font fontListItem = new Font("微软雅黑", 0, 18);
            label.setFont(fontListItem);
            label.setForeground(Color.white);

            JLabel tickLabel= new JLabel("  √");
            tickLabel.setFont(fontListItem);
            tickLabel.setForeground(Color.white);

            JPanel Right =  new JPanel(new BorderLayout());
            Right.add(new JButton("#"),BorderLayout.EAST);

            panel.add(tickLabel,BorderLayout.WEST);
            panel.add(label,BorderLayout.CENTER);
            panel.add(Right,BorderLayout.EAST);

            TaskLookPanel.taskList.add(panel);
//            TaskLookPanel.taskList.add(new Label(task.getContent()));
        }
    }
}
